<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .box {
            /*盒子绝对定位后水平垂直居中*/
            position: absolute;
            left: 50%;
            /*margin-left: -200px;*/
            top: 50%;
            /*margin-top: -200px;*/
            /*位移：自身盒子高度和宽度的一半*/
            transform: translate(-50%, -50%);
            width: 400px;
            height: 400px;
            background-color: pink;
        }
    </style>
</head>
<body>
<div class="box">
</div>
</body>
</html>